<!DOCTYPE html>
<html>
<head>
    <style>
        /* 轮播图容器样式 */
        .slideshow-container {
            max-width: 1000px;
            position: relative;
            margin: auto;
        }

        /* 隐藏默认显示的幻灯片 */
        .mySlides {
            display: none;
        }

        /* 幻灯片图片样式 */
        .mySlides img {
            width: 100%;
            vertical-align: middle;
        }

        /* 上一张/下一张按钮 */
        .prev, .next {
            cursor: pointer;
            position: absolute;
            top: 50%;
            width: auto;
            padding: 16px;
            margin-top: -22px;
            color: white;
            font-weight: bold;
            font-size: 18px;
            transition: 0.6s ease;
            border-radius: 0 3px 3px 0;
            user-select: none;
            background-color: rgba(0,0,0,0.5);
        }

        /* 下一张按钮位置 */
        .next {
            right: 0;
            border-radius: 3px 0 0 3px;
        }

        /* 悬停时背景颜色 */
        .prev:hover, .next:hover {
            background-color: rgba(0,0,0,0.8);
        }

        /* 指示点样式 */
        .dot-container {
            text-align: center;
            padding: 20px;
        }

        .dot {
            cursor: pointer;
            height: 15px;
            width: 15px;
            margin: 0 2px;
            background-color: #bbb;
            border-radius: 50%;
            display: inline-block;
            transition: background-color 0.6s ease;
        }

        .active, .dot:hover {
            background-color: #717171;
        }

        /* 淡入动画 */
        .fade {
            animation-name: fade;
            animation-duration: 1.5s;
        }

        @keyframes fade {
            from {opacity: .4}
            to {opacity: 1}
        }
    </style>
</head>
<body>

<!-- 轮播图容器 -->
<div class="slideshow-container">
    <!-- 幻灯片 -->
    <div class="mySlides fade">
        <img src="img/1.webp" style="width:100%">
        <div class="text">第一张图片</div>
    </div>

    <div class="mySlides fade">
        <img src="img/2.webp" style="width:100%">
        <div class="text">第二张图片</div>
    </div>

    <div class="mySlides fade">
        <img src="img/3.webp" style="width:100%">
        <div class="text">第三张图片</div>
    </div>

    <!-- 导航按钮 -->
    <a class="prev" onclick="plusSlides(-1)">❮</a>
    <a class="next" onclick="plusSlides(1)">❯</a>
</div>

<!-- 指示点 -->
<div class="dot-container">
    <span class="dot" onclick="currentSlide(1)"></span>
    <span class="dot" onclick="currentSlide(2)"></span>
    <span class="dot" onclick="currentSlide(3)"></span>
</div>

<script>
    let slideIndex = 1;
    showSlides(slideIndex);

    // 导航控制
    function plusSlides(n) {
        showSlides(slideIndex += n);
    }

    // 指示点控制
    function currentSlide(n) {
        showSlides(slideIndex = n);
    }

    function showSlides(n) {
        let i;
        let slides = document.getElementsByClassName("mySlides");
        let dots = document.getElementsByClassName("dot");
        
        if (n > slides.length) {slideIndex = 1}
        if (n < 1) {slideIndex = slides.length}
        
        // 隐藏所有幻灯片
        for (i = 0; i < slides.length; i++) {
            slides[i].style.display = "none";
        }
        
        // 取消所有指示点的激活状态
        for (i = 0; i < dots.length; i++) {
            dots[i].className = dots[i].className.replace(" active", "");
        }
        
        // 显示当前幻灯片并激活对应指示点
        slides[slideIndex-1].style.display = "block";
        dots[slideIndex-1].className += " active";
    }

    // 自动播放（可选）
    setInterval(() => {
        plusSlides(1);
    }, 5000);
</script>

</body>
</html>
